package com.erp.myAdapter

import androidx.appcompat.app.AlertDialog
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.erp.R
import com.erp.bean.ProductionExecuteBean
import com.erp.module.ProductionExecute.ProdutionExecuteContract
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_production_yhh_item.view.*

class ProductionYhhAdapter(private val kv : ProdutionExecuteContract.ProductionActivityKV, private val mlist: List<ProductionExecuteBean.plmd_yhhbean>, private val mcontext: Context) : RecyclerView.Adapter<ProductionYhhAdapter.ViewHolder>() {
    internal var width = 0

    override fun onCreateViewHolder(parent: ViewGroup, p1: Int): ProductionYhhAdapter.ViewHolder {
        val view: View = LayoutInflater.from(parent.getContext()).inflate(R.layout.lv_production_yhh_item, parent, false)
        return ViewHolder(view)
    }

    override fun getItemCount(): Int {
        return mlist.size
    }

    override fun onBindViewHolder(h: ProductionYhhAdapter.ViewHolder, position: Int) {
        var bean = mlist[position]
        Myutil.settv(bean.amount,h.tv_amount)
        Myutil.settv(bean.color,h.tv_color)
        Myutil.settv(bean.thickness,h.tv_thickness)
        Myutil.settv(Myutil.getdata(bean.productive_time),h.tv_productive_time)
        h.v.setOnClickListener {
            kv.inventory_supplier_dialog(bean)
        }
    }

    class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        var tv_color : TextView
        var tv_thickness : TextView
        var tv_amount : TextView
        var tv_productive_time : TextView
        var v: View
        init {
            v = view
            tv_color = view.TvColor
            tv_amount = view.TvAmount
            tv_thickness = view.TvThickness
            tv_productive_time = view.TvProductiveTime
        }
    }


}
